<?php
	header('content-type:text/html;charset=utf-8'); 
	
	$dbdata = array();
	$i=0;
	
	
	$Order = $_POST["Order"];//$Order="FA180529009";
	$dbName = "sqlsrv:Server=172.31.3.12,1433;Database=UFDATA_001_2017";   //这里是服务器IP地址和数据库名，端口不是默认的话记得改一下
	$dbUser = "sa";
	$dbPassword = "TDled!2018";
	$db = new PDO($dbName, $dbUser, $dbPassword);   //這裡是PDO鏈接方法
	/* $pdo =new pdo("mysql:host=127.0.0.1;port=3306;dbname=tddb;","root","tdled2018");
	$pdo->query("set character set 'utf8'");//读库 
	$pdo->query("set names 'utf8'");//写库  */
	$sql = 
	"select 
		t2.LotID,t3.ProductID,t3.Qty,t2.Lotno,t2.Catcode,t1.MaterialNumber,t1.ProductID,t3.ProductionNumber
	from 
		ldx_PhilipsOutBoxPrint t1 
	inner join 
		ldx_PhilipsOutBoxList t2 
	on 
		t2.PrintID=t1.PrintID 
	inner join 
		ldx_PhilipsLablesList t3 
	on t3.PrintEwm=t2.Lotno

	WHERE 
		FahuodanNumber='".$Order."'"
	;
	
	$res = $db->query($sql);
	
	while ($row = $res->fetch()){
		$dbdata[$i]=$row;
		$i=$i+1;
	}
	
	//Print array in JSON format
	echo json_encode($dbdata);
	
?>
